﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.Infrastructure;

namespace ERPStore.QuoteCart.Repositories
{
	public class DbContextFactory : CloudSoft.Repositories.IDbContextFactory<QuoteCartDbContext>
	{
		public QuoteCartDbContext GetDbContext()
		{
			var csn = Configuration.ConfigurationSettings.AppSettings["connectionStringName"];
			var result = new QuoteCartDbContext(csn);
			result.Configuration.ProxyCreationEnabled = false;
			result.Configuration.AutoDetectChangesEnabled = true;
			result.Configuration.LazyLoadingEnabled = true;
			return result;
		}

		public System.Data.Entity.Infrastructure.IObjectContextAdapter GetObjectContextAdapter()
		{
			var dbContext = GetDbContext();
			return (IObjectContextAdapter)dbContext;
		}

		public void Dispose()
		{
		}
	}
}
